package com.zuzhili.database;

import java.util.ArrayList;
import java.util.List;

import android.database.sqlite.SQLiteDatabase;

public class DataCtrlBase
{
	protected SQLiteDatabase m_db;
	List<OnDataChanged> listeners=new ArrayList<OnDataChanged>();
	public void setDataChangedListener(OnDataChanged lis){
		listeners.add(lis);
	}
	public void removeDataChangedListener(OnDataChanged lis){
		listeners.remove(lis);
	}
	protected void onDataChanged(){
		for(OnDataChanged rec:listeners){
			rec.onDataChanged();
		}
	}
	public void setDB(SQLiteDatabase db){
		m_db=db;
	}
	protected void beginT() {
		m_db.beginTransaction();
	}	
	protected void endT() {
		m_db.setTransactionSuccessful();
		m_db.endTransaction();
	}
}
